package appconfig

import (
	"fmt"

	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		Host     string
		Port     int
		User     string
		Password string
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
}

var ConfigData AppConfig

func Init() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("读取失败")
	}
	err = viper.Unmarshal(&ConfigData)
	if err != nil {
		panic("解析失败")
	}
	fmt.Println("配置文件成功", ConfigData)
}
